package com.camera2.activity;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.camera2.local.SharedPrefer;


public class FramentMy extends Fragment {

    private TextView name;
    private TextView id;


    @Override
    public View onCreateView(android.view.LayoutInflater inflater,
                             android.view.ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.frament_my, null);

        name = view.findViewById(R.id.tv_my_name);
        id = view.findViewById(R.id.tv_my_id);

        view.findViewById(R.id.my_devices).setOnClickListener(listener);
        view.findViewById(R.id.my_addDevice).setOnClickListener(listener);

        view.findViewById(R.id.my_safe).setOnClickListener(listener);
        view.findViewById(R.id.my_setup).setOnClickListener(listener);

        String name1 = SharedPrefer.ReadUsername(getActivity());
        name.setText(name1);
        String id1 = SharedPrefer.Readid(getActivity());
        id.setText(id1);

        return view;
    }

    OnClickListener listener = new OnClickListener() {
        public void onClick(View v) {
            Intent intent;
            switch (v.getId()) {
                case R.id.my_devices:
//                    intent = new Intent(getActivity(), Mydevice.class);
//                    startActivity(intent);
                    break;
                case R.id.my_addDevice:
//                    intent = new Intent(getActivity(), MyAddUsers.class);
//                    startActivity(intent);
                    break;
                case R.id.my_safe:
                    intent = new Intent(getActivity(), MyModify.class);
                    startActivity(intent);
                    break;
                case R.id.my_setup:
                    intent = new Intent(getActivity(), MySetting.class);
                    startActivity(intent);
                    break;
            }
        }
    };
}